<%@ page language="java" pageEncoding="utf-8" contentType="text/html;charset=UTF-8"%>
<script type="text/javascript">
	$(function(){
		$(".search-page a").click(function(){
			var pageNo = $(this).attr("page");
			//var pageSize = pageObject.pageSize ? pageObject.pageSize:10;
	    	var url = pageObject.url + "?pageNo="+pageNo;//+"&pageSize="+pageSize ;
	    	if(pageObject.params != undefined  )
	    		url += pageObject.params;
	    	
	    	location.href = url;
		});
	});
</script>
<%!
public String toPageString(Integer page ,Integer pageCount, int delta ){
	StringBuffer result = new StringBuffer();
	
	if(delta<1 || delta>10 ) delta = 10;
	
	String[] img = { "首页","上页","下页","末页" };
	
	int num = page.intValue() % delta;
	int nextDelta = page.intValue()+1+( num ==0 ? 0:( delta- num ) );
	
	/*************************************************************************************/
	if( page.intValue() > 1  ){
		if(!StringUtil.isEmpty(img[0]))
			result.append( "<a href='####' page=1 target='_self' title=\"首页\" class='first'>").append( img[0]).append( "</a> ");
		if(!StringUtil.isEmpty(img[1]))
			result.append( "<a href='####' page="+(page.intValue() - 1)+" target='_self' title=\"上一页\" class='prev'>").append( img[1]).append( "</a> ");
	}
	
	for( int i= Math.max(nextDelta - delta, 1) ; i <= pageCount.intValue() && i< nextDelta ; i++ ){
		if( i == page.intValue() )
			result.append( "<a href='####' page="+i+" target='_self' class='search-page-count current'>").append(i).append( "</a>");
		else
			result.append( "<a href='####' page="+i+" target='_self' class='search-page-count'>").append(i).append( "</a>");
	}
	
	if( page.intValue() < pageCount.intValue()){
		if(!StringUtil.isEmpty(img[2]) )
			result.append( "<a href='####' page="+(page.intValue() + 1) +" target='_self' title=\"下一页\" class='next'>").append( img[2]).append( "</a> ");
		if(!StringUtil.isEmpty(img[3]))
			result.append( "<a href='####' page="+pageCount.intValue()+" target='_self' title=\"末页\" class='last'>").append( img[3]).append( "</a> ");
	}
	
	return result.toString();
}
%>
<%
    PageTurn pageTurn = (PageTurn)request.getAttribute("pageTurn");
	String pageString ="";
	if (pageTurn != null) {
    	pageString = toPageString(pageTurn.getPage(),pageTurn.getPageCount(),5);
	}
    request.setAttribute("pageString",pageString);
%>
<div class="search-page">
	${pageString}
</div>